<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function foo(a,b){
            if( a > b){
                var c = 0;
                c = a;
                a = b;
                b = c;
            }
            var c = 0;
            function f1(){
                for(var i=a;i <= a;i--){
                    if(a%i == 0 && b%i == 0){
                        return i;
                    }
                }
            }
            f1();
            console.log(a*b/f1());
        }
        foo(12,16);
    </script>
</body>
</html>